<!doctype html>
<html lang="zh-CH">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<!-- <meta name="viewport" content="width=device-width, initial-scale=1"> -->
	<title>木投网--个人中心--购物车</title>
	<link rel="stylesheet" href="/resource/css/mt_index.css">
	<link rel="stylesheet" href="/resource/css/mt_user.css">
	<link rel="stylesheet" href="/resource/css/mt_showBo.css">
</head>
<body>
<!-- 顶部 -->
<div class="head">
	<div class="top-nav">
		<div class="main">
			<div class="left">
				<!-- 登录后 -->
				 <span class="login-after">
                    您好，{{session_get(UserEnum::USER_INFO_SESSION_KEY)->user_name}}（{{substr(session_get(UserEnum::USER_INFO_SESSION_KEY)->mobile,0,3)}}****{{substr(session_get(UserEnum::USER_INFO_SESSION_KEY)->mobile,7)}}）
                    <a href="/logout">退出</a>
                </span>
			</div>
			<div class="right">
				<ul>
					<li><a href="/user_account">我的木投网</a><span>|</span></li>
					<li><a href="/user_order?status=0">我的订单</a><span>|</span></li>
					<li><a href="javascript:;">在线客服</a><span>|</span></li>
					<li><span class="last">客服热线：400-036-7917</span></li>
				</ul>
			</div>
		</div>
	</div>
	<div class="top">
		<div class="main">
			<div class="logo left">
				<a href="/"><img src="/resource/img/user_logo.png" alt=""></a>
			</div>
			<div class="logo-info left">
				我的购物车
				<a href="/">返回首页</a>
			</div>
		</div>
	</div>
</div>
@if(!$data)
<!-- 购物车空 -->
<div class="shopping-none main">
	<div class="none-wrap">
		<i></i>
		<div class="info">
			购物车空空的哦~，去看看心仪的商品吧~<br/>
			<a href="/">去购物&#62</a>
		</div>
	</div>
</div>
@else
<!-- 购物车内容 -->
<div class="shopping-cont main" id="list">
	<div class="title">
		<div class="til">全部商品<span>{{$count}}</span>个</div>
	</div>
	<div class="shopping-wrap" >
		@foreach($data as $v)
		<div class="table info-font">
			<table>
				<thead>
					<tr>
						<th width="">商品信息</th>
						<th width="160px">库存</th>
						<th width="220px">单价</th>
						<th width="180px">数量</th>
						<th width="200px">合计（元）</th>
						<th width="170px">操作</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td>
							<a href="/shopping_details/?product_id={{$v->product_id}}" target="blank"><img src="{{$v->product_img}}" alt=""></a>
							<a href="/shopping_details/?product_id={{$v->product_id}}" target="blank">{{$v->product_name}}</a>
						</td>
						<td class="stock-num"><div>{{$v->stock}}{{$v->unit}}</div></td>
						<td class="price"><div>￥{{$v->price}}</div></td>
						<td>
							<div class="info-num">
								<a href="javascript:;" class="pre" onclick="reduce_num({{$v->product_id}})"></a>
								<input type="text" id="info-num" placeholder="{{$v->number}}" value="{{$v->number}}" onblur="check_num({{$v->product_id}})">
								<a href="javascript:;" class="next" onclick="add_num({{$v->product_id}})"></a>
								<span id="t_num" hidden>库存不足</span>
							</div>
						</td>
						<td class="total"><span >￥{{$v->price*$v->number}}</span></td>
						<td>
							<a href="javascript:;" class="a-delete" data-cart_id="{{ $v->cart_id }}">删除</a>
							<a href="/shop_cart_submit?cart_id={{$v->cart_id}}" class="btn-accounts">去结算</a>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		@endforeach
	</div>
</div>
<div class="delete-all main">
	<a href="javascript:;" data-cart_id="all"><i></i>清空购物车</a>
</div>
@endif
<!-- 底部 -->
<div class="foot">
	<div class="main">
		<div class="left">
			<div class="foot-nav">
				<dl>
					<dt><span>如何买木材</span></dt>
					<dd>
						<a href="javascript:;" target="_blank">如何委托找货</a>
						<a href="javascript:;" target="_blank">如何自己找货</a>
						<a href="javascript:;" target="_blank">如何支付</a>
					</dd>
				</dl>
				<dl>
					<dt><span>如何卖木材</span></dt>
					<dd>
						<a href="javascript:;" target="_blank">如何入驻木投网</a>
						<a href="javascript:;" target="_blank">如何发布商品</a>
						<a href="javascript:;" target="_blank">如何收款</a>
					</dd>
				</dl>
				<dl>
					<dt><span>常见问题</span></dt>
					<dd>
						<a href="javascript:;" target="_blank">采购流程</a>
						<a href="javascript:;" target="_blank">委托物流</a>
						<a href="javascript:;" target="_blank">意见反馈</a>
					</dd>
				</dl>
			</div>
			<div class="foot-info">
				<ul>
					<li><a href="javascript:;">关于我们</a><span>|</span></li>
					<li><a href="javascript:;">法律声明</a><span>|</span></li>
					<li><a href="javascript:;">诚聘英才</a><span>|</span></li>
					<li><a href="javascript:;">投资洽谈</a><span>|</span></li>
					<li><a href="javascript:;">联系我们</a><span>|</span></li>
					<li><a href="javascript:;">常见问题</a></li>
				</ul>
				<p>北京木投网科技有限公司 京ICP备15043001   Copyright © 2016  Mutouw.com 版权所有</p>
			</div>
		</div>
		<div class="foot-code right">
			<img src="/resource/img/foot_code.png" alt="">
		</div>
	</div>
</div>
<!-- 返回顶部 -->
<div class="pos-tooblar">
	<a href="javascript:;" class="pos-tooblar-time">
		<span class="tooblar-later"></span>
	</a>
	<a href="javascript:;" class="pos-tooblar-service">
		<span class="tooblar-later"></span>
	</a>
	<a href="javascript:;" class="pos-tooblar-tel">
		<span class="tooblar-later"></span>
	</a>
	<a href="javascript:;" class="pos-tooblar-top" id="backTop"></a>
</div>
	<a href="javascript:;" class="pos-tooblar-time">
		<span class="tooblar-later"></span>
	</a>
	<a href="javascript:;" class="pos-tooblar-service">
		<span class="tooblar-later"></span>
	</a>
	<a href="javascript:;" class="pos-tooblar-tel">
		<span class="tooblar-later"></span>
	</a>
	<a href="javascript:;" class="pos-tooblar-top" id="backTop"></a>
</div>
<script src="/resource/js/jquery-1.11.3.min.js"></script>
<script src="/resource/js/mt_index.js"></script>
<script src="/resource/js/mt_showBo.js"></script>  <!-- 提示信息 -->
<script src="/resource/js/T.js"></script>
<script>
	//点击删除全部
	$('.delete-all a').click(function(){
		var data = $(this).data();
		Showbo.Msg.confirm('<img class="left" src="/resource/img/user_if.png" alt=""><span style="float:left;font-size:22px;color:#221815;text-align:left;line-height:34px;">清空购物车？ <br/><i class="font-size:14px;color:#898989;">购物车的商品会全部消失</i></span>',function(btn){
			if (btn == 'yes') {
				T.restPost('/shop_cart_delete', data, function (response) {
					if (response.data.state) {
						T.ajaxLoad('/shop_cart_ajax', 'list', function () {
						});
					} else {
						alert("刪除失敗");
					}
				});
			}else{
				return false;
			};
		});
		$('input.btn+input.btn').css('margin-right','-100px');
	});



	//点击删除单个
	$(document).delegate('.a-delete','click',function(){
		var data = $(this).data();
		Showbo.Msg.confirm('<img class="left" src="/resource/img/user_if.png" alt=""><span style="float:left;font-size:22px;">确定删除该商品？</span>',function(btn){
			if (btn == 'yes') {
				T.restPost('/shop_cart_delete', data, function (response) {
					if (response.data.state) {
						T.ajaxLoad('/shop_cart_ajax', 'list', function () {
						});
					} else {
						alert("刪除失敗");
					}
				});
			}else{
				return false;
			};
		});
		$('input.btn+input.btn').css('margin-right','-78px');
	});


	function ajax(product_id,product_num){
			$.ajax({
		 url: "/shop_update_cart",
		 type: "POST",
		 data: "product_id=" + product_id+"&product_num="+product_num,
		 success: function (msg) {
		 if(msg!=1){
			 $("#t_num").show()
		 }
		 }
		 })
	}

	function check_num(product_id){
		var num = $("#info-num").val();
		ajax(product_id,num);
	}

	function reduce_num(product_id){
		var num = $("#info-num").val()-1;
		ajax(product_id,num);
	}

	function add_num(product_id){
		var num = parseInt($("#info-num").val())+1;
		ajax(product_id,num);
	}
</script>
</body>
</html>